@namespace Counter.Components

@using Microsoft.AspNetCore.Components
@using Microsoft.AspNetCore.Components.Web
@using RazorConsole.Components
@using Spectre.Console

<Figlet Content="Counter Example" />
<Newline />

<Panel Title="Counter" Border="BoxBorder.Rounded" Expand="true">
    <Rows>
        <Columns>
            <Markup Content="Current count:" Foreground="@Color.Grey70" />
            <Markup Content="@currentCount.ToString()" Foreground="@Color.Green" Decoration="@Decoration.Bold" />
        </Columns>
        <Newline />
        <Columns>
            <TextButton Content="Increment"
                        OnClick="IncrementCount"
                        BackgroundColor="@Color.Grey"
                        FocusedColor="@Color.Blue" />
            <TextButton Content="Decrement"
                        OnClick="DecrementCount"
                        BackgroundColor="@Color.Grey"
                        FocusedColor="@Color.Red" />
            <TextButton Content="Reset"
                        OnClick="ResetCount"
                        BackgroundColor="@Color.Grey"
                        FocusedColor="@Color.Yellow" />
        </Columns>
    </Rows>
</Panel>

<Newline />
<Markup Content="Press Tab to change focus • Press Enter to click • Press Ctrl+C to exit" Foreground="@Color.Grey58" />

@code {
    private int currentCount = 0;

    private void IncrementCount()
    {
        currentCount++;
    }

    private void DecrementCount()
    {
        currentCount--;
    }

    private void ResetCount()
    {
        currentCount = 0;
    }
}
